package com.heima.dome1;

import com.heima.domain.Student;

import java.util.Scanner;

public class TestStudent {
    public static void main(String[] args) {
        Student s=new Student();
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入名字：");
        String name=sc.nextLine();
        s.setName(name);

        while (true){
            System.out.println("请输入年龄：");
            String agestring=sc.nextLine();
            try {
                int age=Integer.parseInt(agestring);
                s.setAge(age);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数");
            }catch (RuntimeException e) {
                System.out.println(e.toString());
                System.out.println("请输入一个符合条件的数");
            }
        }
        System.out.println(s);
    }
}
